package com.hnkywl.sts.action.tjbb;

import com.hnkywl.sts.service.tjbb.YjykhhzbService;
import net.ruixin.web.struts2.SimpleActionSupport;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Date;

/**
 * Created with IntelliJ IDEA.
 * User: SDE09
 * Date: 13-9-28
 * Time: 下午5:06
 * To change this template use File | Settings | File Templates.
 */
@Namespace("/tjbb/yjykhhz")
public class YjykhhzbAction extends SimpleActionSupport {
    private YjykhhzbService yjykhhzbService;
    private Integer year;
    private Integer month;
    private Date date;
    private Date startDate;
    private Date endDate;
    private Float ll;
    private Integer gsid;
    private int page;
    private int rows;

    @Action("yjykhhz")
    public String yjykhhz() {
        date = new Date();
        return SUCCESS;
    }

    @Action("yjykhhzList")
    public void yjykhhzList() {
        String json = yjykhhzbService.yjykhhzList(year, month);
        renderJson(json);
    }

    @Action("lrcs_content")
    public String lrscContent() {
        return SUCCESS;
    }

    @Action("lrcsList")
    public void lrcsList() {
        String json = yjykhhzbService.findLrcsList();
        renderJson(json);
    }

    @Action("lrcs_detail")
    public String lrscDetail() {
        int mons;
        if (month < 10) {
            mons = Integer.parseInt(String.valueOf(year) + ("0" + String.valueOf(month)));
        } else {
            mons = Integer.parseInt(String.valueOf(year) + String.valueOf(month));
        }
        return SUCCESS;
    }

    @Action("lrcs_update")
    public void lrcsUpdate() {
        try {
            yjykhhzbService.updateLrcs(year, month, ll);
            renderText("{\"statusCode\":\"200\", \"message\":\"修改利润参数成功\"}");
        } catch (Exception e) {
            e.printStackTrace();
            renderText("{\"statusCode\":300,\"message\":\"" + e.getMessage() + "\"}");
        }
    }

    @Action("sjsr")
    public String sjsr() {
        return SUCCESS;
    }

    //实际收入
    @Action("sjsrlist")
    public void sjsrlist() {
        renderText(yjykhhzbService.sjsr(gsid, year, month, page, rows));
    }

    @Action("zjcb")
    public String zjcb() {
        return SUCCESS;
    }

    //资金成本
    @Action("zjcblist")
    public void zjcblist() {
        renderText(yjykhhzbService.zjcb(gsid, year, month));
    }


    //==============getter====setter=================


    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public int getRows() {
        return rows;
    }

    public void setRows(int rows) {
        this.rows = rows;
    }

    public Integer getYear() {
        return year;
    }

    public void setYear(Integer year) {
        this.year = year;
    }

    public Integer getGsid() {
        return gsid;
    }

    public void setGsid(Integer gsid) {
        this.gsid = gsid;
    }

    public Integer getMonth() {
        return month;
    }

    public void setMonth(Integer month) {
        this.month = month;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public Date getStartDate() {
        return startDate;
    }

    public void setStartDate(Date startDate) {
        this.startDate = startDate;
    }

    public Date getEndDate() {
        return endDate;
    }

    public void setEndDate(Date endDate) {
        this.endDate = endDate;
    }

    public Float getLl() {
        return ll;
    }

    public void setLl(Float ll) {
        this.ll = ll;
    }

    @Autowired
    public void setYjykhhzbService(YjykhhzbService yjykhhzbService) {
        this.yjykhhzbService = yjykhhzbService;
    }
}
